<template>
  <el-dialog
    :title="dialogTitle + '周转批次'"
    :visible.sync="batchDialog"
    width="38%"
    customClass="mes_dialog work_order_batch"
    v-dialogDrag
    :close-on-click-modal="false"
    @closed="closed">
    <div class="dialog_remarks">
      <!--<span class="remarks_title">备注</span>-->
      <div class="remarks_cont">
        <el-input
          type="textarea"
          resize="none"
          v-model="remarks"
          maxlength="255"
          :autosize="{ minRows: 1, maxRows: 3}"
          placeholder="可以输入说明原因，非必填">
        </el-input>
      </div>
    </div>
    <span slot="footer" class="mes_btn" :class="{has_box:value === 'Pause'}">
      <div v-if="value === 'Pause'">
        <el-checkbox v-model="isInputSemisStore">在制品入库</el-checkbox>
        <span class="check_tip">（只有周转进度状态为“生产中”的才能发起）</span>
      </div>
      <div>
        <el-button type="primary" @click="submit">提交</el-button>
        <el-button @click="batchDialog = false">取消</el-button>
      </div>
    </span>
  </el-dialog>
</template>

<script>
export default {
  name: 'WorkOrderBatch',
  props: {
    // type: String,
    // batchList: Array
  },
  data() {
    return {
      // 显示弹框
      batchDialog: false,
      // 备注
      remarks: '',
      // 批次ids
      statusId: '',
      // 批次状态值
      value: '',
      // 弹窗标题
      dialogTitle: '',
      // 暂停时是否在制品入库
      isInputSemisStore: false,
    }
  },
  methods: {
    // 打开弹框
    openDialog(statusId, value) {
      this.statusId = statusId
      this.value = value
      this.remarks = ''
      this.batchDialog = true
      this.getDialogTitle(value)
    },
    // 获取弹窗标题
    getDialogTitle(value) {
      switch (value) {
        case 'Pause':
          this.dialogTitle = '暂停'
          break
        case 'PartTerminate':
          this.dialogTitle = '分级终止'
          break
        case 'Terminate':
          this.dialogTitle = '终止'
          break
        case 'Resume':
          this.dialogTitle = '恢复'
          break
      }
    },
    // 提交
    submit() {
      let obj = {
        statusId: this.statusId,
        value: this.value,
        reason: this.remarks,
        isInputSemisStore: this.value === 'Pause' ? this.isInputSemisStore : undefined
      }
      this.$emit('submitBatch', obj)
      this.batchDialog = false
    },
    closed() {
      this.isInputSemisStore = false
    }
  }
}
</script>

<style scoped lang="less">
  .work_order_batch{
    .dialog_alert {
      flex: 1;
    }
    .table_container{
      margin-bottom: 20px;
    }
    .dialog_remarks{
      height: 60px;
      display: flex;
      align-items: center;
      border: 1px solid #dbe1e8;
      .remarks_title{
        flex: 0 0 120px;
        text-align: center;
        height: 60px;
        line-height: 60px;
        border-right: 1px solid #dbe1e8;
      }
      .remarks_cont{
        flex: 1;
        .el-textarea__inner{
          padding-top: 0px;
          padding-bottom: 0px;
          line-height: 18px;
        }
      }
    }
    .mes_btn.has_box{
      justify-content: space-between;
      .check_tip{
        color:#666;
        font-size:12px;
      }
    }
  }
</style>
<style lang="less">
  .work_order_batch {
    .remarks_cont {
      .el-textarea__inner {
        border: 0;
        font-size: 14px;
        padding-top: 0px;
        padding-bottom: 0px;
        line-height: 18px;
      }
    }
  }
</style>
